<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Statistics extends API_Controller {


	public function __construct() {
    	parent::__construct();
	}

	public function record_visitor(){

		$this->load->helper('ip');
		$ip = getip();

		$this->load->model('visitor');
		$exist_ip = $this->visitor->is_exist($ip);

		if($exist_ip){
			$affected  = $this->visitor->plus($ip);
		}else{
			$insertData = array();
			$insertData = array(
				'ip' => $ip,
				'visit_count' => 1
			);
			$affected = $this->visitor->insert($insertData);
		}
	}

	if($affected){
		$this->to_api_message(1,'记录成功');
	}else{
		$this->to_api_message(0, '记录失败');
	}

}